<template>
    <view class="uni-shadow u-p-b-30" @tap.stop="detail">
        <u-row class="u-flex u-flex-wrap">
            <u-col v-for="(item,index) in list" :key="index" :span="item.span" 
                :class="['u-font-26','col',index==0?'u-m-b-10':'u-m-t-20']">
                <text :class="['u-m-r-20','u-line-1',index==0?'u-font-28 font-bold':'uni-dec-color']">{{item.title}}</text>
                <uni-phone v-if="item.type=='phone'" :phone="item.value" :size="13" />
                <text v-else class="u-line-1" style="max-width:80%" @longtap="longTap(item.value)">{{item.value}}</text>
            </u-col>
        </u-row>
        <!-- 提示组件 -->
        <u-toast ref="uToast"></u-toast>
    </view>
</template>


<script>
export default {
    name: 'enterpriseItem',
    title:'企业管理',
    props:{
        listData:{
            type: Object,
            default(){
                return {}
            }
        }
    },

    data(){
        return{
            list: [
                // 原数据 据(基础信息优化工作20220326_APP优化)文档修改
                // { fied:'qymc', title:'企业名称', value:'' },
                // { fied:'qylx', title:'单位类型', value:'暂无数据源' },
                // { fied:'districtName', title:'所属区划', value:'暂无数据源' },
                // { fied:'qyjydz', title:'单位地址', value:'暂无数据源' },
                // { fied:'tyshxydm', title:'信用代码', value:'暂无数据源' },
                // { fied:'number', title:'项目总数', value:'暂无数据源' },
                // { fied:'dwdh', title:'单位电话', value:'暂无数据源', type:'phone' },
                { fied:'qymc', title:'单位名称', span:12, value:'' },
                { fied:'qylx', title:'用户类型', span:6, value:'安薪乐' },
                { fied:'dwlx1', title:'单位类型', span:6, value:'安薪乐' },
                { fied:'tyshxydm', title:'统一社会信用代码', span:12, value:'安薪乐' },
                { fied:'qygszcszd', title:'注册地址', span:12, value:'安薪乐' },
                { fied:'number', title:'项目总数', span:12, value:'安薪乐' },
            ]
        }
    },
    

    created() {
        this.list.map((v,i)=>{
            if( v.fied == 'qymc' ){
                v.title = this.listData[v.fied]?this.listData[v.fied]:'暂无数据源'
            }else{
                v.value = this.listData[v.fied]?this.listData[v.fied]:'暂无数据源'
            }
        })
    },

    methods: {
        // 长按事件
        longTap(value){
            this.$refs.uToast.show({
                message: value,
                type: 'default',
                duration: 3000
            })
        },
        // 企业详情
        detail(){
            uni.navigateTo({ url: '/pages/enterprise-bag/tab?id='+this.listData.id })
        }
    },
}
</script>


<style scoped lang="scss">
    .col{
        flex-direction: row;
    }
</style>